]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
PopupMenu: make parameters overridable in items
authorGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 25 Jan 2011 21:06:40 +0000 (22:06 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 21 Feb 2011 18:54:10 +0000 (19:54 +0100)
Make all subclasses of PopupMenuBase accept a params argument, which
can be used to make the item non reactive, not responsive to hover
and, as a new feature, with a different style class.

https://bugzilla.gnome.org/show_bug.cgi?id=621707

js/ui/popupMenu.js
js/ui/statusMenu.js

index 05a67bd87af478981f3fab515b3ed1d518369f14..e3aeffe1080fb33e85de3fdd515c37e09dd75327 100644 (file)
@@ -26,7 +26,9 @@ PopupBaseMenuItem.prototype = {
     _init: function (params) {
         params = Params.parse (params, { reactive: true,
                                          activate: true,
-                                         hover: true });
+                                         hover: true,
+                                         style_class: null
+                                       });
         this.actor = new Shell.GenericContainer({ style_class: 'popup-menu-item',
                                                   reactive: params.reactive,
                                                   track_hover: params.reactive,
@@ -43,6 +45,9 @@ PopupBaseMenuItem.prototype = {
         this._spacing = 0;
         this.active = false;
 
+        if (params.style_class)
+            this.actor.add_style_class_name(params.style_class);
+
         if (params.reactive && params.activate) {
             this.actor.connect('button-release-event', Lang.bind(this, this._onButtonReleaseEvent));
             this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
@@ -527,8 +532,8 @@ function PopupSwitchMenuItem() {
 PopupSwitchMenuItem.prototype = {
     __proto__: PopupBaseMenuItem.prototype,
 
-    _init: function(text, active) {
-        PopupBaseMenuItem.prototype._init.call(this);
+    _init: function(text, active, params) {
+        PopupBaseMenuItem.prototype._init.call(this, params);
 
         this.label = new St.Label({ text: text });
         this._switch = new Switch(active);
@@ -555,15 +560,15 @@ PopupSwitchMenuItem.prototype = {
     }
 };
 
-function PopupImageMenuItem(text, iconName) {
-    this._init(text, iconName);
+function PopupImageMenuItem() {
+    this._init.apply(this, arguments);
 }
 
 PopupImageMenuItem.prototype = {
     __proto__: PopupBaseMenuItem.prototype,
 
-    _init: function (text, iconName) {
-        PopupBaseMenuItem.prototype._init.call(this);
+    _init: function (text, iconName, params) {
+        PopupBaseMenuItem.prototype._init.call(this, params);
 
         this.label = new St.Label({ text: text });
         this.addActor(this.label);
@@ -608,8 +613,12 @@ PopupMenuBase.prototype = {
     _init: function(sourceActor, styleClass) {
         this.sourceActor = sourceActor;
 
-        this.box = new St.BoxLayout({ style_class: styleClass,
-                                      vertical: true });
+        if (styleClass !== undefined) {
+            this.box = new St.BoxLayout({ style_class: styleClass,
+                                          vertical: true });
+        } else {
+            this.box = new St.BoxLayout({ vertical: true });
+        }
 
         this.isOpen = false;
         this._activeMenuItem = null;
index ecc12b0440c56014fbfb14d6db64d0cf2c517139..dc17f0f7f8ac0d257dc0476eddcfe5daa4a26813 100644 (file)
@@ -99,12 +99,12 @@ StatusMenuButton.prototype = {
     _createSubMenu: function() {
         let item;
 
-        item = new PopupMenu.PopupImageMenuItem(_("Available"), 'user-available', true);
+        item = new PopupMenu.PopupImageMenuItem(_("Available"), 'user-available');
         item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.AVAILABLE));
         this.menu.addMenuItem(item);
         this._presenceItems[GnomeSession.PresenceStatus.AVAILABLE] = item;
 
-        item = new PopupMenu.PopupImageMenuItem(_("Busy"), 'user-busy', true);
+        item = new PopupMenu.PopupImageMenuItem(_("Busy"), 'user-busy');
         item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.BUSY));
         this.menu.addMenuItem(item);
         this._presenceItems[GnomeSession.PresenceStatus.BUSY] = item;